<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition  xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template/studentTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content1">
        <style>
            .content-area{
                min-height: 100px;
            }
        </style>
        <script>
            $(function() {
                $("#accordion").accordion();
            });
        </script>
        <script type="text/javascript" src="../../ckeditor/ckeditor.js"></script>
        <p:dialog modal="true" widgetVar="statusDialog" header="Status" draggable="false" closable="false" resizable="false">  
            <p:graphicImage value="/design/ajaxloadingbar.gif" />  
        </p:dialog> 
        <h:form id="form">
            <div class="col-6 ol-lg-6 col-sm-6">
                <div class="form-group">

                    <p:accordionPanel id="acc" value="#{mailView.currListMC}" var="mc" activeIndex="#{mailView.maxIndex}">
                        <p:tab title="#{mc.entities.title}, by #{mc.accountsBySenderId.fullName}, at #{mc.entities.startTime}">  
                            <div>
                                <h:commandButton value="Delete" action="#{staffInbox.toTrash(mc)}" />
                             
                            </div>
                            <h:panelGrid columns="2" cellpadding="10">  

                                <fieldset>
                                    <legend>Content</legend>

                                    #{mc.entities.content }

                                </fieldset>
                            </h:panelGrid>
                            <ul>
                                <ui:repeat value="#{staffInbox.getAttachmentsList(mc.entities)}" var="a" >
                                    <li>#{a.fileName}
                                        <p:commandButton id="downloadLink"  value="Download" ajax="false"
                                                         icon="ui-icon-arrowthichk-s">  
                                            <p:fileDownload  value="#{fileDownloadBean.loadFile(a.attachmentUrl, a.fileName)}" />  
                                        </p:commandButton>  
                                    </li>
                                </ui:repeat>
                            </ul>
                        </p:tab>  
                    </p:accordionPanel>

                    <div>
                        <h:inputTextarea id="textarea" value="#{mailView.replyContent}" />
                        <script type="text/javascript">
                            //<![CDATA[
                            CKEDITOR.replace('form:textarea');
                            //]]>
                        </script> 
                        <h:commandButton styleClass="btn btn-default" value="Reply" action="#{mailView.reply()}"  >
                            <!--<f:ajax render="acc" listener="" />-->
                        </h:commandButton>
                        <input type="reset" class="btn btn-default" value="Reset" />
                    </div>

                </div>
            </div>

        </h:form> 

    </ui:define>

</ui:composition>
